﻿Imports System.Transactions
Imports CondorTravel.BE
Imports CondorTravel.DALC

Public Class ServicioBC

    Public Function InsertarServicio(ByVal objServicioBE As ServicioBE, ByRef iCodigoServicio As Integer, ByRef bExito As Boolean, ByRef sMensaje As String) As Boolean

        Dim objScope As TransactionScope
        objScope = New TransactionScope


        Using objScope
            Try
                Dim objServicioDALC As ServicioDALC = Nothing
                objServicioDALC = New ServicioDALC

                objServicioDALC.InsertarServicio(objServicioBE, iCodigoServicio, bExito, sMensaje)

                objScope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return bExito
    End Function

    Public Function InsertarDetalleServicio(ByVal objServicioBE As ServicioBE, ByRef bExito As Boolean, ByRef sMensaje As String) As Boolean

        Dim objScope As TransactionScope
        objScope = New TransactionScope


        Using objScope
            Try
                Dim objServicioDALC As ServicioDALC = Nothing
                objServicioDALC = New ServicioDALC

                objServicioDALC.InsertarDetalleServicio(objServicioBE, bExito, sMensaje)

                objScope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return bExito
    End Function

    Public Function InsertarTarifaServicio(ByVal objServicioBE As ServicioBE, ByRef bExito As Boolean, ByRef sMensaje As String) As Boolean

        Dim objScope As TransactionScope
        objScope = New TransactionScope


        Using objScope
            Try
                Dim objServicioDALC As ServicioDALC = Nothing
                objServicioDALC = New ServicioDALC

                objServicioDALC.InsertarTarifaServicio(objServicioBE, bExito, sMensaje)

                objScope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return bExito
    End Function

    Public Function InsertarDistribucionServicio(ByVal objServicioBE As ServicioBE, ByRef bExito As Boolean, ByRef sMensaje As String) As Boolean

        Dim objScope As TransactionScope
        objScope = New TransactionScope


        Using objScope
            Try
                Dim objServicioDALC As ServicioDALC = Nothing
                objServicioDALC = New ServicioDALC

                objServicioDALC.InsertarDistribucionServicio(objServicioBE, bExito, sMensaje)

                objScope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return bExito
    End Function

    Public Function ModificaCabeceraServicio(ByVal objServicioBE As ServicioBE, ByRef bExito As Boolean, ByRef sMensaje As String) As Boolean

        Dim objScope As TransactionScope
        objScope = New TransactionScope


        Using objScope
            Try
                Dim objServicioDALC As ServicioDALC = Nothing
                objServicioDALC = New ServicioDALC

                objServicioDALC.ModificaCabeceraServicio(objServicioBE, bExito, sMensaje)

                objScope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return bExito
    End Function


    Public Function ModificaDetalleServicio(ByVal objServicioBE As ServicioBE, ByRef bExito As Boolean, ByRef sMensaje As String) As Boolean

        Dim objScope As TransactionScope
        objScope = New TransactionScope


        Using objScope
            Try
                Dim objServicioDALC As ServicioDALC = Nothing
                objServicioDALC = New ServicioDALC

                objServicioDALC.ModificaDetalleServicio(objServicioBE, bExito, sMensaje)

                objScope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return bExito
    End Function

    Public Function EliminarServicio(ByVal objServicioBE As ServicioBE, ByRef bExito As Boolean, ByRef sMensaje As String) As Boolean

        Dim objScope As TransactionScope
        objScope = New TransactionScope


        Using objScope
            Try
                Dim objServicioDALC As ServicioDALC = Nothing
                objServicioDALC = New ServicioDALC

                objServicioDALC.EliminarServicio(objServicioBE, bExito, sMensaje)

                objScope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return bExito
    End Function


    Public Function ValidarExisteServicioAsociado(ByVal objServicioBE As ServicioBE) As Integer

        Dim objScope As TransactionScope
        objScope = New TransactionScope
        Dim iSolicitud As Integer

        Using objScope
            Try
                Dim objServicioDALC As ServicioDALC = Nothing
                objServicioDALC = New ServicioDALC

                iSolicitud = objServicioDALC.ValidarExisteServicioAsociado(objServicioBE)
                objScope.Complete()
            Catch ex As Exception
                MsgBox(ex.Message, vbCritical, "Error del sistema")
                Return Nothing
                Exit Function
            End Try
        End Using

        Return iSolicitud

    End Function


    Public Function ListarDtsServicio(ByVal objServicioBE As ServicioBE) As DataSet
        Dim dts As New DataSet
        Dim objServicioDALC As ServicioDALC = Nothing

        objServicioDALC = New ServicioDALC
        dts = objServicioDALC.ListaDtsServicio(objServicioBE)

        Return dts
    End Function

    Public Function ServicioListarSel() As List(Of ServicioBE)
        Try
            Dim listServicioBE As List(Of ServicioBE) = Nothing
            Dim objServicioDALC As ServicioDALC = Nothing

            objServicioDALC = New ServicioDALC
            listServicioBE = New List(Of ServicioBE)()
            listServicioBE = objServicioDALC.ListarServicioSel

            Return listServicioBE

        Catch ex As Exception
            MsgBox(ex.Message, vbCritical, "Error del sistema")
            Return Nothing
            Exit Function
        End Try
    End Function


    Public Function ListarServicioBusq(ByVal objServBE As ServicioBE) As List(Of ServicioBE)

        Dim objServicio As List(Of ServicioBE) = Nothing
        Dim objServicioDALC As ServicioDALC = Nothing

        objServicioDALC = New ServicioDALC
        objServicio = New List(Of ServicioBE)()
        objServicio = objServicioDALC.ListarServicioBusq(objServBE)

        Return objServicio
    End Function

    Public Function ListaServicioCiudad(ByVal objServBE As ServicioBE) As List(Of ServicioBE)

        Dim objServicio As List(Of ServicioBE) = Nothing
        Dim objServicioDALC As ServicioDALC = Nothing

        objServicioDALC = New ServicioDALC
        objServicio = New List(Of ServicioBE)()
        objServicio = objServicioDALC.ListaServicioCiudad(objServBE)

        Return objServicio
    End Function


    Public Function ListarServicioList(ByVal objServBE As ServicioBE) As List(Of ServicioBE)

        Dim objServicio As List(Of ServicioBE) = Nothing
        Dim objServicioDALC As ServicioDALC = Nothing

        objServicioDALC = New ServicioDALC
        objServicio = New List(Of ServicioBE)()
        objServicio = objServicioDALC.ListaServicioList(objServBE)

        Return objServicio
    End Function

    Public Function ListarCabeceraServicioList(ByVal objServicioBE As ServicioBE, ByRef bExito As Boolean, ByRef sMensaje As String) As List(Of ServicioBE)

        Dim objServicio As List(Of ServicioBE) = Nothing
        Dim objServicioDALC As ServicioDALC = Nothing

        objServicioDALC = New ServicioDALC
        objServicio = New List(Of ServicioBE)()
        objServicio = objServicioDALC.ListarCabeceraServicio(objServicioBE, bExito, sMensaje)

        Return objServicio
    End Function

    Public Function ListarDetalleServicioList(ByVal objServicioBE As ServicioBE, ByRef dt As DataTable, ByRef bExito As Boolean, ByRef sMensaje As String) As List(Of ServicioBE)

        Dim objServicio As List(Of ServicioBE) = Nothing
        Dim objServicioDALC As ServicioDALC = Nothing

        objServicioDALC = New ServicioDALC
        objServicio = New List(Of ServicioBE)()
        objServicio = objServicioDALC.ListarDetalleServicio(objServicioBE, dt, bExito, sMensaje)

        Return objServicio
    End Function

End Class
